package r

import (
	"gin-fileserver/pkg/e"
	"net/http"

	"github.com/gin-gonic/gin"
)

func R(c *gin.Context, httpCode int, code int, data map[string]interface{}) {
	c.JSON(httpCode, gin.H{
		"code": code,
		"msg":  e.GetMsg(code),
		"data": data,
	})
}

func OK(c *gin.Context, code int, data map[string]interface{}) {
	R(c, http.StatusOK, code, data)
}

func Error(c *gin.Context, code int, err string) {
	R(c, http.StatusOK, code, map[string]interface{}{"error": err})
}
